package com.googlecode.gwtbb.client.only.remote.forum;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.googlecode.gwtbb.client.only.GwtUtils;
import com.googlecode.gwtbb.client.only.glue.events.GwtbbEvents;
import com.googlecode.gwtbb.client.only.remote.ClientResponseEventCallback;
import com.googlecode.gwtbb.client.shared.remote.forum.CreatePostBean;
import com.googlecode.gwtbb.client.shared.remote.forum.CreatePostResponse;

/**
 * @author Abraham Grief
 * @version $Id$
 * @since Apr 30, 2008
 */
public class PostServiceProxy implements PostServiceAsync {
	private static final PostServiceProxy instance = new PostServiceProxy();

	PostServiceAsync real = (PostServiceAsync)GwtUtils.createProxy(GWT.create(PostService.class), "/gwtbbExporter/postService");

	public static PostServiceProxy instance() {
		return instance;
	}

	public void create(Long userId, String sessionId, CreatePostBean createPostBean, AsyncCallback async) {
		real.create(userId, sessionId, createPostBean, new ClientResponseEventCallback<CreatePostResponse>(async) {
			public void raiseEvent(CreatePostResponse serverResponse) {
				GwtbbEvents.instance().fireCreatePostEvent(serverResponse);
			}
		});
	}
}